export type RequestResultType<T> = {
	code: RequestStatus | number;
	data: T;
	message?: string;
};

export enum RequestStatus {
	SUCCESS = "0000",
	NO_AUTH = "601",
}

export type ResultFunction<T> = {
	onSuccess?: (data: T, raw: RequestResultType<T>) => void;
	onError?: (error: RequestResultType<T> | Error) => void;
	onComplete?: (result: RequestResultType<T> | Error) => void;
};

export interface RequestState {
	isLoading: boolean;
	isError: boolean;
	errorMessage?: string;
	retryCount: number;
}

export interface RequestOptions<TParams> {
	retryTimes?: number;
	retryDelay?: number;
	timeout?: number;
	autoRetry?: boolean;
	defaultParams?: TParams;
}
